package com.msk.common.wechatV3.base;

import com.msk.common.utils.StringUtils;
import com.msk.common.wechatV3.config.WxPayV3Config;

import java.math.BigDecimal;

/**
 * @desc: 通用支付请求模型
 * @author: zlf
 * @date: 2021-09-13 15:53
 **/
public class CommonOrder {

    /**
     * 订单编号
     */
    private String orderNo;

    /**
     * 订单金额
     */
    private BigDecimal orderAmount;

    /**
     * 通知地址
     */
    private String notifyUrl;

    /**
     * 终端IP
     */
    private String spbillCreateIp;

    /**
     * 附加数据，在查询API和支付通知中原样返回，可作为自定义参数使用
     */
    private String attach;

    /**
     * 订单ID
     */
    private String orderId;

    /**
     * 购买内容
     */
    private String orderContent;

    /**
     * 微信支付配置
     */
    private WxPayV3Config wxPayV3Config;

    public String getOrderNo() {
        return orderNo;
    }

    public void setOrderNo(String orderNo) {
        this.orderNo = orderNo;
    }

    public BigDecimal getOrderAmount() {
        return orderAmount;
    }

    public void setOrderAmount(BigDecimal orderAmount) {
        this.orderAmount = orderAmount;
    }

    public String getNotifyUrl() {
        return notifyUrl;
    }

    public void setNotifyUrl(String notifyUrl) {
        this.notifyUrl = notifyUrl;
    }

    public String getSpbillCreateIp() {
        return spbillCreateIp;
    }

    public void setSpbillCreateIp(String spbillCreateIp) {
        this.spbillCreateIp = spbillCreateIp;
    }

    public String getAttach() {
        return attach;
    }

    public void setAttach(String attach) {
        this.attach = attach;
    }

    public String getOrderId() {
        return orderId;
    }

    public void setOrderId(String orderId) {
        this.orderId = orderId;
    }

    public String getOrderContent() {
        return orderContent;
    }

    public void setOrderContent(String orderContent) {
        this.orderContent = orderContent;
    }

    public WxPayV3Config getWxPayV3Config() {
        return wxPayV3Config;
    }

    public void setWxPayV3Config(WxPayV3Config wxPayV3Config) {
        this.wxPayV3Config = wxPayV3Config;
    }

    /**
     * 校验订单支付体
     * @return
     */
    public boolean checkCommonOrderInfo() {
        boolean flag = true;
        if (StringUtils.isEmpty(getOrderNo())) {
            flag = false;
        } else if (getOrderAmount() == null || orderAmount.compareTo(BigDecimal.ZERO) <= 0) {
            flag = false;
        } else if (StringUtils.isEmpty(getNotifyUrl())) {
            flag = false;
        } else if (StringUtils.isEmpty(getSpbillCreateIp())) {
            flag = false;
        } else if (StringUtils.isEmpty(getAttach())) {
            flag = false;
        }
        return flag;
    }

    /**
     * 校验V3订单支付体
     * @return
     */
    public boolean checkCommonOrderV3Info() {
        boolean flag = true;
        if (StringUtils.isEmpty(getOrderNo())) {
            flag = false;
        } else if (getOrderAmount() == null || orderAmount.compareTo(BigDecimal.ZERO) <= 0) {
            flag = false;
        } else if (StringUtils.isEmpty(getNotifyUrl())) {
            flag = false;
        }
        return flag;
    }

    /**
     * 校验接口订单支付体
     * @return
     */
    public boolean checkApiCommonOrderInfo() {
        boolean flag = true;
        if (StringUtils.isEmpty(getOrderNo())) {
            flag = false;
        } else if (getOrderAmount() == null || orderAmount.compareTo(BigDecimal.ZERO) <= 0) {
            flag = false;
        } else if (StringUtils.isEmpty(getOrderId())) {
            flag = false;
        }
        return flag;
    }
}
